const fs = require('fs');

function fromJSONFile(filename) {
    return (req, res) => {
        const data = fs.readFileSync(`mock/data/${filename}.json`).toString();
        const json = JSON.parse(data);
        return res.json(json);
    };
}

const proxy = {
    /**
     * @name mock数据配置
     * @description  格式说明： ｜Method(大写)｜API (接口)｜response (对应mock/data 目录下的文件名)｜
     **/
    'GET /haha': fromJSONFile('getData'),
};

module.exports = proxy;
